//
//  NMDimmingNode.swift
//  NetEaseMusic
//
//  Created by SAGESSE on 2020/3/15.
//  Copyright © 2020 SAGESSE. All rights reserved.
//

import UIKit
import AsyncDisplayKit


class NMDimmingNode: ASControlNode {
    
    
    override var backgroundColor: UIColor? {
        get { return originBackgroundColor }
        set {
            originBackgroundColor = newValue
            updateBackgroundColor()
        }
    }
    
    override var isHighlighted: Bool {
        didSet {
            updateBackgroundColor()
        }
    }
    
    override init() {
        super.init()
        self.isUserInteractionEnabled = true
    }
    
    private func updateBackgroundColor() {
        
        if isHighlighted {
            super.backgroundColor = originBackgroundColor?.withAlphaComponent(0.5)
        } else {
            super.backgroundColor = originBackgroundColor
        }

    }
    
    private var originBackgroundColor: UIColor?
}


//class NMTextHighlightNode: ASControlNode {
//    
//    init?(_ node: ASDisplayNode, at point: CGPoint) {
////        super.init()
//        return nil
//    }
//    
//    override var isHighlighted: Bool {
//        didSet {
//            logger.debug?.write()
//        }
//    }
//    
//    override func cancelTracking(with touchEvent: UIEvent?) {
//        super.cancelTracking(with: touchEvent)
//        
//        self.supernode?.setNeedsDisplay()
//        self.removeFromSupernode()
//    }
//    override func endTracking(with touch: UITouch?, with touchEvent: UIEvent?) {
//        super.endTracking(with: touch, with: touchEvent)
//        self.supernode?.setNeedsDisplay()
//        self.removeFromSupernode()
//    }
//    
//}
